'''
Created on Jul 10, 2010

@author: dgentry
'''

import sqlite3

if __name__ == '__main__':
    #  open database
    
    conn = sqlite3.connect('db')
    
    c1 = conn.cursor()
    
    #  clear table
    
    print "Clearing previous list"
    
    c1.execute('DELETE FROM podcasts')
    
    conn.commit()
    
    #  open file for read
    
    print "Loading podcasts"
    
    f = open('episodes.txt', 'r')
    
    #  write each record
    
    for line in f:
        lf = line.split('    ')
        # t is: title, url
        t = (lf[0], lf[1])    
        c1.execute('insert into podcasts values (?,?)', t)
    
    #  close database
    conn.commit()
    f.close()
    
    print "Load complete"